<?php

/**
 * 鸡蛋白活动页面
 * 编写人   陈泽富
*/

define('IN_ECS', true);
define('IS_MOBILE', true);
require(dirname(__FILE__) . '/../includes/init.php');

$act = !empty($_REQUEST['act'])?$_REQUEST['act']:'';


/* 众筹版面模块 */
$smarty->assign('top_title', "一起呐喊吧");
/* 当前筹集金额 */
/* 开始时间：23号09：30分 */
$sTime = strtotime('2015-08-23 09:30:00');
$time = time();
/* 截止数据时间 */
$vtime[] = strtotime('2015-08-23 09:30:00');
$vtime[] = strtotime('2015-08-23 18:00:00');
$vtime[] = strtotime('2015-08-24 18:00:00');
$vtime[] = strtotime('2015-08-25 18:00:00');
$vtime[] = strtotime('2015-08-26 18:00:00');
/* 截止数据最低要求 */
$number = array(0, 1532, 3582, 4508, 5000);
$vkey = 0; // 当前时间所在键值
foreach ($vtime as $key => $value) {
    if ($time >= $value) $vkey = $key;
}
/* 计算当前所需值 */
if ($time <= $sTime) {
    $num = 0;
} elseif ($vkey != 4) {
    $sTime = $vtime[$vkey];
    $num = $number[$vkey];
    $a = $vtime[$vkey + 1] - $sTime;
    $b = $time - $sTime;
    $n = intval(($b / $a) * ($number[$vkey+1] - $number[$vkey]));
    $num += $n;
} else {
    $num = 5000;
}
$smarty->assign('num', $num); // 已参与人数
$smarty->assign('money', $num * 10); // 筹集金额

$smarty->display('glairPoject.dwt');
